<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>人机交互分类游戏</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Comic Sans MS', '微软雅黑', sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #6ecbf5 0%, #059ee3 100%);
            min-height: 100vh;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        
        .container {
            max-width: 1000px;
            width: 100%;
            background-color: rgba(255, 255, 255, 0.9);
            border-radius: 20px;
            padding: 20px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
            text-align: center;
        }
        
        h1 {
            color: #ff6b6b;
            margin-bottom: 15px;
            font-size: 2.2rem;
            text-shadow: 2px 2px 0 #ffd166;
        }
        
        .instructions {
            background-color: #ffd166;
            padding: 15px;
            border-radius: 15px;
            margin-bottom: 20px;
            font-size: 1.2rem;
            color: #333;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
        
        .game-area {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            gap: 20px;
            margin-bottom: 20px;
        }
        
        .category {
            flex: 1;
            min-width: 300px;
            background-color: #a8e6cf;
            border-radius: 15px;
            padding: 15px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
        
        .category h2 {
            color: #1a936f;
            margin-bottom: 15px;
            font-size: 1.6rem;
        }
        
        .drop-zone {
            min-height: 300px;
            border: 3px dashed #1a936f;
            border-radius: 10px;
            padding: 10px;
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: center;
            align-items: flex-start;
            transition: all 0.3s;
        }
        
        .drop-zone.active {
            background-color: rgba(168, 230, 207, 0.5);
            border-style: solid;
        }
        
        .items-container {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            justify-content: center;
            margin-bottom: 20px;
        }
        
        .item {
            width: 120px;
            height: 120px;
            background-color: white;
            border-radius: 15px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 10px;
            cursor: grab;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            transition: all 0.3s;
            position: relative;
        }
        
        .item:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
        }
        
        .item.dragging {
            opacity: 0.7;
            transform: scale(1.05);
        }
        
        .item img {
            width: 60px;
            height: 60px;
            object-fit: contain;
            margin-bottom: 8px;
        }
        
        .item span {
            font-size: 0.9rem;
            text-align: center;
            color: #333;
        }
        
        .controls {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin-top: 20px;
        }
        
        button {
            background-color: #ff6b6b;
            color: white;
            border: none;
            border-radius: 50px;
            padding: 12px 25px;
            font-size: 1.2rem;
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }
        
        button:hover {
            background-color: #ff5252;
            transform: translateY(-3px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
        }
        
        button:active {
            transform: translateY(1px);
        }
        
        .score {
            font-size: 1.5rem;
            color: #1a936f;
            margin: 10px 0;
            font-weight: bold;
        }
        
        .feedback {
            font-size: 1.3rem;
            margin: 10px 0;
            min-height: 40px;
            font-weight: bold;
        }
        
        .correct {
            color: #1a936f;
        }
        
        .incorrect {
            color: #ff6b6b;
        }
        
        .item.correct-item {
            background-color: #c8f7dc;
            border: 2px solid #1a936f;
        }
        
        .item.incorrect-item {
            background-color: #ffd1d1;
            border: 2px solid #ff6b6b;
        }
        
        .completion-message {
            background-color: #ffd166;
            padding: 20px;
            border-radius: 15px;
            margin-top: 20px;
            font-size: 1.5rem;
            color: #333;
            display: none;
        }
        
        @media (max-width: 768px) {
            .game-area {
                flex-direction: column;
            }
            
            .category {
                min-width: 100%;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>人机交互分类游戏</h1>
        
        <div class="instructions">
            <p>请将下面的物品拖到正确的分类区域中！</p>
            <p>需要人机交互：人们需要通过操作、触摸或语音等方式与设备互动</p>
            <p>不需要人机交互：设备可以独立工作，不需要人们直接操作</p>
        </div>
        
        <div class="score">得分: <span id="score">0</span>/12</div>
        <div class="feedback" id="feedback"></div>
        
        <div class="game-area">
            <div class="category">
                <h2>需要人机交互</h2>
                <div class="drop-zone" id="interactive-zone">
                    <!-- 拖拽到这里的内容 -->
                </div>
            </div>
            
            <div class="category">
                <h2>不需要人机交互</h2>
                <div class="drop-zone" id="non-interactive-zone">
                    <!-- 拖拽到这里的内容 -->
                </div>
            </div>
        </div>
        
        <div class="items-container" id="items-container">
            <!-- 物品将通过JavaScript动态添加 -->
        </div>
        
        <div class="controls">
            <button id="check-btn">检查答案</button>
            <button id="reset-btn">重新开始</button>
        </div>
        
        <div class="completion-message" id="completion-message">
            太棒了！你已经完成了分类游戏！你真是个小小科技专家！
        </div>
    </div>

    <script>
        // 游戏数据
        const items = [
            { id: 1, name: "传统电话", category: "interactive", image: "📞" },
            { id: 2, name: "语音助手", category: "interactive", image: "🗣️" },
            { id: 3, name: "电脑鼠标", category: "interactive", image: "🖱️" },
            { id: 4, name: "电子书阅读器", category: "interactive", image: "📖" },
            { id: 5, name: "电视遥控器", category: "interactive", image: "📺" },
            { id: 6, name: "扫描仪", category: "interactive", image: "📷" },
            { id: 7, name: "传统闹钟", category: "non-interactive", image: "⏰" },
            { id: 8, name: "电磁炉", category: "interactive", image: "🍳" },
            { id: 9, name: "自动贩卖机", category: "interactive", image: "🥤" },
            { id: 10, name: "智能手机", category: "interactive", image: "📱" },
            { id: 11, name: "智能手表", category: "interactive", image: "⌚" },
            { id: 12, name: "书本", category: "non-interactive", image: "📚" }
        ];

        // 游戏状态
        let score = 0;
        let placedItems = 0;
        let draggedItem = null;

        // DOM元素
        const itemsContainer = document.getElementById('items-container');
        const interactiveZone = document.getElementById('interactive-zone');
        const nonInteractiveZone = document.getElementById('non-interactive-zone');
        const scoreElement = document.getElementById('score');
        const feedbackElement = document.getElementById('feedback');
        const checkButton = document.getElementById('check-btn');
        const resetButton = document.getElementById('reset-btn');
        const completionMessage = document.getElementById('completion-message');

        // 初始化游戏
        function initGame() {
            // 清空区域
            itemsContainer.innerHTML = '';
            interactiveZone.innerHTML = '';
            nonInteractiveZone.innerHTML = '';
            
            // 重置游戏状态
            score = 0;
            placedItems = 0;
            scoreElement.textContent = score;
            feedbackElement.textContent = '';
            feedbackElement.className = 'feedback';
            completionMessage.style.display = 'none';
            
            // 创建物品元素
            items.forEach(item => {
                const itemElement = document.createElement('div');
                itemElement.className = 'item';
                itemElement.draggable = true;
                itemElement.dataset.id = item.id;
                itemElement.dataset.category = item.category;
                
                itemElement.innerHTML = `
                    <div style="font-size: 40px;">${item.image}</div>
                    <span>${item.name}</span>
                `;
                
                // 添加拖拽事件
                itemElement.addEventListener('dragstart', handleDragStart);
                itemElement.addEventListener('dragend', handleDragEnd);
                
                itemsContainer.appendChild(itemElement);
            });
            
            // 设置放置区域
            setupDropZone(interactiveZone);
            setupDropZone(nonInteractiveZone);
        }

        // 设置放置区域
        function setupDropZone(zone) {
            zone.addEventListener('dragover', handleDragOver);
            zone.addEventListener('dragenter', handleDragEnter);
            zone.addEventListener('dragleave', handleDragLeave);
            zone.addEventListener('drop', handleDrop);
        }

        // 拖拽事件处理
        function handleDragStart(e) {
            draggedItem = this;
            this.classList.add('dragging');
            e.dataTransfer.setData('text/plain', this.dataset.id);
        }

        function handleDragEnd() {
            this.classList.remove('dragging');
            draggedItem = null;
            
            // 移除所有放置区域的高亮
            document.querySelectorAll('.drop-zone').forEach(zone => {
                zone.classList.remove('active');
            });
        }

        function handleDragOver(e) {
            e.preventDefault();
        }

        function handleDragEnter(e) {
            e.preventDefault();
            this.classList.add('active');
        }

        function handleDragLeave() {
            this.classList.remove('active');
        }

        function handleDrop(e) {
            e.preventDefault();
            this.classList.remove('active');
            
            if (draggedItem) {
                // 如果物品已经在某个区域中，先移除
                if (draggedItem.parentElement.classList.contains('drop-zone')) {
                    draggedItem.parentElement.removeChild(draggedItem);
                    placedItems--;
                }
                
                // 将物品添加到当前区域
                this.appendChild(draggedItem);
                placedItems++;
                
                // 检查是否所有物品都已放置
                if (placedItems === items.length) {
                    checkButton.disabled = false;
                }
            }
        }

        // 检查答案
        function checkAnswers() {
            let correctCount = 0;
            
            // 检查交互区域的物品
            const interactiveItems = interactiveZone.querySelectorAll('.item');
            interactiveItems.forEach(item => {
                const itemId = item.dataset.id;
                const itemData = items.find(i => i.id == itemId);
                
                if (itemData.category === 'interactive') {
                    item.classList.add('correct-item');
                    correctCount++;
                } else {
                    item.classList.add('incorrect-item');
                }
            });
            
            // 检查非交互区域的物品
            const nonInteractiveItems = nonInteractiveZone.querySelectorAll('.item');
            nonInteractiveItems.forEach(item => {
                const itemId = item.dataset.id;
                const itemData = items.find(i => i.id == itemId);
                
                if (itemData.category === 'non-interactive') {
                    item.classList.add('correct-item');
                    correctCount++;
                } else {
                    item.classList.add('incorrect-item');
                }
            });
            
            // 更新分数
            score = correctCount;
            scoreElement.textContent = score;
            
            // 显示反馈
            if (score === items.length) {
                feedbackElement.textContent = "太棒了！全部正确！";
                feedbackElement.className = 'feedback correct';
                completionMessage.style.display = 'block';
            } else {
                feedbackElement.textContent = `你答对了 ${score} 个，继续加油！`;
                feedbackElement.className = 'feedback incorrect';
            }
            
            // 禁用检查按钮
            checkButton.disabled = true;
        }

        // 事件监听
        checkButton.addEventListener('click', checkAnswers);
        resetButton.addEventListener('click', initGame);

        // 初始化游戏
        window.addEventListener('DOMContentLoaded', initGame);
    </script>
</body>
</html>